"use strict"
/** @param {import("egg").Application} app */
module.exports = app => {
	const Sequelize = app.Sequelize
	const sequelize = app.model
	let gameUser = sequelize.define("gameUser", {
		total_coin: {
			defaultValue: 0,
			type: Sequelize.DOUBLE
		}, // 总资产
		popularity: {//声望
			defaultValue: 0,
			type: Sequelize.DOUBLE
		},
		sycee: {
			defaultValue: 0,
			type: Sequelize.INTEGER
		},
		oid: {
			type: Sequelize.INTEGER,
			comment: " 当前用户的id",
			// unique: true
		},
		inviteid: {//  
			type: Sequelize.INTEGER,
			comment: "初次,邀请人的id"
		},
		last_login: {
			type: Sequelize.DATE,
			defaultValue: sequelize.literal("CURRENT_TIMESTAMP"),
			get() {
				return Date.parse(this.getDataValue("last_login"))
			}
		},
		level: {// 用户的等级预留
			type: Sequelize.INTEGER,
			defaultValue: 1
		},
		invite_reward: {
			type: Sequelize.BOOLEAN,
			defaultValue: false
		},
		invite_num: {  // 切换 邀请的人数
			type: Sequelize.SMALLINT,
			defaultValue: 0,
			comment: "第几个邀请的人, 如用户邀请第一个人就是1,第二个人就是2"
		},
		sell_count: {// 商店的轮次
			type: Sequelize.INTEGER,
			defaultValue: 0
		},
		unlock_map: {
			type: Sequelize.INTEGER,
			defaultValue: 1
		},
		ip: {
			type: Sequelize.INTEGER.UNSIGNED
		},
		max_total_coin: {
			defaultValue: 0,
			type: Sequelize.DOUBLE
		},
		max_popularity: {
			defaultValue: 0,
			type: Sequelize.DOUBLE
		},
		create_at: {
			type: Sequelize.DATE,
			defaultValue: sequelize.literal("CURRENT_TIMESTAMP"),
			get() {
				return Date.parse(this.getDataValue("create_at"))
			}
		},
	}, {
		timestamps: false,
		tableName: "empire_user",
	})
	return gameUser
}